{
PROB : dining
LANG : PASCAL
ID : phamnamlo2
}

program DINING;
const
  fi = 'dining.in';
  fo = 'dining.out';
  max = 301;
var
  a, flow : array[0..max, 0..max] of longint;
  trace : array[0..max] of longint;
  free : array[0..max] of shortint;
  n, f, d, s, t, res : longint;

procedure init;
var
  i : longint;
begin
  res := 0;
  s := 0;
  t := n+f+d+1;
  fillchar(a, sizeof(a), 0);
  fillchar(flow, sizeof(flow), 0);
  for i := 1 to f do a[s, i] := 1;
  for i := f+n+1 to f+n+d do a[i, t] := 1;
  fillchar(free, sizeof(free), 0);
end;

procedure inp;
var
  i, j, nf, nd : longint;
  fi, di : longint;
begin
  read(n, f, d);
  init;
  for i := 1 to n do
  begin
    read(nf, nd);
    for j := 1 to nf do
    begin
      read(fi);
      a[fi, f+i] := 1;
    end;
    for j := 1 to nd do
    begin
      read(di);
      a[f+i, f+n+di] := 1;
    end;
  end;
end;

function foundpath : boolean;
var
  q : array[1..max+1] of longint;
  u, v, l, r : longint;
begin
  fillchar(trace, sizeof(trace), $FF);
  l := 1;
  r := 1;
  q[1] := s;
  while l <= r do
  begin
    u := q[l];
    inc(l);
    for v := s to t do
      if (trace[v] = -1) and (flow[u, v] < a[u, v]) then
      begin
        if (f < v) and (v < f+n+1) then
          if free[v] = 1 then continue;
        trace[v] := u;
        if v = t then
        begin
          foundpath := true;
          exit;
        end;
        inc(r);
        q[r] := v;
      end;
  end;
  foundpath := false;
end;

procedure incflow;
var
  u, v : longint;
begin
  inc(res);
  v := t;
  while v <> s do
  begin
    u := trace[v];
    inc(flow[u, v]);
    dec(flow[v, u]);
    v := u;
    if (f < u) and (v < f+n+1) then free[u] := free[u] xor 1;
  end;
end;

procedure process;
begin
  while foundpath do incflow;
end;

procedure out;
begin
  writeln(res);
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);

  inp;
  process;
  out;

  close(output);
  close(input);
end.
